package admin.board.board_list.dao;

import java.sql.SQLException;
import java.util.List;

import util.SqlMapLocator;

import admin.board.board_list.dto.BoardlistDto;

public class BoardlistDao {
	private static BoardlistDao instance = new BoardlistDao();
	public static BoardlistDao getInstance() { return instance; }
	private BoardlistDao() {}
	
	@SuppressWarnings("unchecked")
	public List<BoardlistDto> list(int category_no) throws SQLException {
		return (List<BoardlistDto>)SqlMapLocator.getMapper().queryForList("boardlist.list", category_no);
	}
	
	@SuppressWarnings("unchecked")
	public List<BoardlistDto> list() throws SQLException {
		return (List<BoardlistDto>)SqlMapLocator.getMapper().queryForList("boardlist.listAll");
	}
	
	public BoardlistDto selectOne(int board_no) throws SQLException {
		return (BoardlistDto)SqlMapLocator.getMapper().queryForObject("boardlist.selectOne", board_no);
	}
	
	public void delete(int board_no) throws SQLException {
		SqlMapLocator.getMapper().delete("boardlist.delete", board_no);
	}
	
	public void insert(BoardlistDto dto) throws SQLException {
		SqlMapLocator.getMapper().insert("boardlist.insert", dto);
	}
	
	public void update(BoardlistDto dto) throws SQLException {
		SqlMapLocator.getMapper().update("boardlist.update", dto);
	}
	
	public String selectName(int category_no) throws SQLException {
		return (String)SqlMapLocator.getMapper().queryForObject("boardlist.selectName", category_no);
	}
	public String selectBoardName(int board_no) throws SQLException {
		return (String)SqlMapLocator.getMapper().queryForObject("boardlist.selectBoardName", board_no);
	}
}
